<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../../layui/css/layui.css">
    <script src="../../layui/layui.js"></script>
    <script src="../../js/jquery.min.js"></script>
    <link rel="stylesheet" href="../../layui/css/formSelects-v4.css">
    <script src="../../js/config.js"></script>
</head>
<body>
<h1>治疗仪器信息</h1>
<hr>
<form action="" class="layui-form">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">医生</label>
            <div class="layui-input-inline">
                <input type="text" id="docname" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">病历号</label>
            <div class="layui-input-inline">
                <input type="text" id="disoddid" autocomplete="off" class="layui-input">
            </div>
        </div>
        <button type="button" class="layui-btn" onclick="reloadData()" lay-submit="" lay-filter="demo1">查询</button>
    </div>
</form>

<table class="layui-hide" id="userList" lay-filter="userList"></table>


<script>
    var table ;
    function reloadData(){
        //执行重载
        table.reload('userList', {
            page: {
                curr: 1 //重新从第 1 页开始
            }
            ,where: {
                docname : $("#docname").val(),
                disoddid: $("#disoddid").val()
            }
        });
    }

    layui.use('form',function () {
        var form = layui.form;
    });
    layui.use(['table','form'], function(){
        table = layui.table;
        var form = layui.form;

        table.render({
            elem: '#userList'
            ,url:'http://localhost:8888/zhiliaoyi/list'
            ,page: true
            ,even : true
            ,toolbar: '#tool'
            ,id : "userList"
            ,cols: [[
                {field:'id', title: '序号', sort: true}
                ,{field:'docname', title: '医生'}
                ,{field:'disoddid', title:'病历号'}
                ,{field:'rname', title: '患者'}
                ,{field:'aid', title: '仪器'}
                ,{field:'zdate', title: '使用时间'}
                ,{field:'zdateover', title: '结束时间'}
                // ,{fixed: 'right', title:'操作', toolbar: '#toolbarDemo', width:150}
            ]]
        });
    });
</script>
<script type="text/html" id="tool">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="add">预约仪器</button>
    </div>
</script>
<script>
    var table ;
    layui.use(['form','table'],function(){
        table = layui.table;
        var form = layui.form;

        //头工具栏事件
        table.on('toolbar(userList)', function(obj){
            switch(obj.event){
                case 'add':
                    $.get('add.html',function (data) {
                        layer.open({
                            title: '预约仪器',
                            type:1,
                            anim:4,
                            skin:'layui-layer-molv',
                            area:'1200px',
                            content:data,
                            maxmin:true,
                            btn : ['确定','取消'],
                            yes : function () {
                                var str = $("#add_user_form").serialize();
                                $.post(`${new Config().base_url}/zhiliaoyi/add`,str,function (data) {
                                    layer.close(layer.index);
                                    table.reload('userList');
                                });
                            }
                        });
                    });
                    break;
                case 'isAll':
                    layer.msg(checkStatus.isAll ? '全选': '未全选');
                    break;
            };
        });

        //监听行内的工具条
        table.on('tool(userList)',function (obj) {
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
        });
    });
</script>
</body>
</html>